package com.kedacom.ctsp.authority.entity;

import com.kedacom.ctsp.web.entity.AbstractTreeSortSupportEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.persistence.*;

/**
 * 资源实体类
 *
 * @author sunchenjie
 * @date 2017/11/12
 */
@Data
@Entity
@Table(name = "resource")
@EqualsAndHashCode(of = "id")
public class SimpleResource extends AbstractTreeSortSupportEntity<Resource, String> implements Resource {

    /**
     * 主键id ，自增长
     */
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @ApiModelProperty("主键id")
    private String id;
    /**
     * 资源名称
     */
    private String name;
    /**
     * 唯一标识（在系统中使用）
     */
    private String sign;
    /**
     * 类型 比如10 菜单 20 操作 30 权限等
     */
    private String type;
    /**
     * 备注
     */
    private String description;
    /**
     * 数据
     */
    private String data;
    /**
     * 对应的url
     */
    private String url;

    /**
     * 可选字段
     */
    @Column(length = 1000)
    private String field;
    /**
     * 数据访问自定义权限
     */
    private String dataAccess;
    /**
     * 数据访问范围
     */
    private String dataScope;

    @ManyToOne(fetch = FetchType.EAGER, targetEntity = SimpleResource.class)
    @JoinColumn(name = "parent_id")
    private Resource parent;

    /**
     * 客户端标识
     */
    private String clientSign;
    /**
     * 扩展字段
     */
    @Column(length = 4000)
    private String extendedField;

    private RequestMethod method;

    public String toString(){
        return "";
    }
}
